package org.fuys.coder.common.holder;

import org.fuys.coder.domain.category.model.vo.CategoryVO;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @projectName: fuys-low-coder
 * @package: org.fuys.coder.common.holder
 * @className: CategoryVOHolder
 * @author: WangJing
 * @description: 分类持有者 多读少写的 使用Map来存储 降低redis压力 因为单体也不需要共享
 * @date: 2024/8/14 16:29
 * @version: 1.0
 */
public class CategoryVOHolder {
    private static Map<Integer, CategoryVO> categoryVOMap=new ConcurrentHashMap<>();

    public static CategoryVO getById(Integer cId){
        return categoryVOMap.get(cId);
    }

    public static void putCategory(CategoryVO categoryVO){
        categoryVOMap.put(categoryVO.getId(),categoryVO);
    }

    public static Collection<CategoryVO> getAll(){
        return categoryVOMap.values();
    }
}
